//
//  ST_TianDailyTaskCellModel.swift
//  btvideo
//
//  Created by Jason on 2021/10/28.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//
import Foundation
import SwiftyJSON

enum ST_DailyMissionState {
    case undone(coin:String?)
    case done
    case received
}


class ST_TianDailyTaskCellModel {
    
    var id : Int
    var actionId : Int
    var gender:Int
    
    var name : String
    var desc : String
    var image : String
    var imageUrl : String
    
    var coin : Int
    var integral : String
    
    var missionState:ST_DailyMissionState
    
//    var hasReceive : Bool
//    var isDone : Bool
    
    /**
     * Instantiate the instance using the passed json values to set the properties values
     */
    init(fromJson json: JSON){
        
        actionId = json["action_id"].intValue
        gender = json["gender"].intValue
        coin = json["coin"].intValue
        desc = json["desc"].stringValue
        id = json["id"].intValue
        image = json["image"].stringValue
        imageUrl = json["image_url"].stringValue
        integral = json["integral"].stringValue
        
        name = json["name"].stringValue

        
        if json["has_receive"].boolValue{
            missionState = .received
        }else if json["is_done"].boolValue{
            missionState = .done
        }else{
            if gender == 2{
                missionState = .undone(coin: json["integral"].stringValue)
            }else{
                if let coin = json["coin"].int,coin > 0{
                    missionState = .undone(coin: coin.string)
                }else{
                    missionState = .undone(coin: nil)
                }
            }
            
        }
        
    }
    
}
